package com.base.cn.platform.os.controller.course.favorites;

import com.base.cn.platform.os.common.controller.BaseController;
import com.base.cn.platform.os.common.utils.result.ResultUtil;
import com.base.cn.platform.os.entity.course.favorites.CourseFavorites;
import com.base.cn.platform.os.service.favorites.CourseFavoritesBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Map;


/**
 * 课程收藏Controller
 *
 * @author s.li
 * @date 2018/10/24
 */
@RestController
@RequestMapping("/course")
public class CourseFavoritesController extends BaseController {
    @Autowired
    private CourseFavoritesBiz courseFavoritesBiz;

    /**
     * 保存用户收藏课记录
     * @param userId 用户ID
     * @param courseId 课程ID
     * @return
     */
    @RequestMapping("/saveCourseFavorites")
    public Map<String,Object> saveCourseFavorites(@RequestParam("userId") BigDecimal userId,
                                             @RequestParam("courseId") BigDecimal courseId){
        Map<String,Object> resultMap = courseFavoritesBiz.saveCourseFavorites(userId,courseId);
        return ResultUtil.SUCCESS(resultMap);
    }

    /**
     * 获取用户的单个课程收藏记录
     * @param userId 用户ID
     * @param courseId 课程ID
     * @return CourseFavorites
     */
    @RequestMapping("/findUserCourseFavorites")
    public CourseFavorites findUserCourseFavorites(@RequestParam("userId") BigDecimal userId,
                                                   @RequestParam("courseId") BigDecimal courseId){
        return courseFavoritesBiz.findUserCourseFavorites(userId,courseId);
    }
}
